<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@include file="../base.jsp"%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>客户查询</title>    
<link href="../css/main.css" rel="stylesheet" type="text/css" >

<link rel="stylesheet" type="text/css" href="../../js/jquery/easyui1.5/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../../js/jquery/easyui1.5/themes/icon.css">
<script type="text/javascript" src="../../js/jquery-1.8.0.min.js"></script>
<script src="../../js/jquery/easyui1.5/jquery.easyui.min.js"></script>
<script src="../../js/jquery/easyui1.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../js/jquery.select.js"></script>
<script type="text/javascript">

var datagrid={
    datagridId:"list",
    datagridUrl:"templateAjax_tableListBySearch.action",
    datagridObj:{
        /*title:"查询列表",*/
        nowrap:true,
        autoRowHeight:false,
        fit:true,
        columns:[
            [
	            {field:'keyRandom',title:'url代码'},
	            {field:'tableName',title:'表名'},
                {field:'tableNameShow',title:'表名显示名'},
                {field:'sql',title:'SQL'},
                {field:'primaryKey',title:'主键'},
                {field:'mode',title:'模式'}
            ]
        ],
        onRowContextMenu: onRowContextMenu,
        rownumbers:true,
		frozenColumns:[[
					]],
        toolbar:[
                 {
                     id:'addA1TemplateTable',
                     text:'添加',
                     iconCls:'icon-add',
                     handler:addA1TemplateTable
                  }
                 ]
    },
    datagridProperty:{
    },
    datagridPropertySort:{
    	id:'默认属性'
    },
    datagridPropertyMultiQuery:{
    }
};


//添加表
function addA1TemplateTable() { 
	$('#A1TemplateTable').show(); 
	$('#A1TemplateTable').dialog({
		modal:true, 
		buttons: [{ 
			text: '提交', 
			iconCls: 'icon-ok', 
			handler: function() { 
				$.ajax({
					type:"POST",
					url:"templateAjax_addA1TemplateTable.action",
					dataType:"json",
					data:{
						'tableName':$('#tableName').val(),
						'tableNameShow':$('#tableNameShow').val(),
						'primaryKey':$('#primaryKey').val()
					},
					success:function(msg){
						var msg = eval("("+msg+")"); 
						if(msg.responseCode==0){
							alert(msg.responseContent);
							return;
						}			
						if(confirm('操作成功\r\n是否刷新数据?')){
							reLoadData(); 
							$('#tableName').val('');
							$('#tableNameShow').val('');
							$('#primaryKey').val('');
							$('#A1TemplateTable').dialog("close");
						}	
						return;
					},
					error:function(er){
						alert('操作失败：请先确认是否授权访问该资源');
					}
				 })
			} 
		}, { 
			text: '取消', 
			iconCls: 'icon-cancel', 
			handler: function() { 
				$('#A1TemplateTable').dialog("close");
			} 
		}] 
	}); 

} 

//添加右击菜单内容
var id;
function onRowContextMenu(e, rowIndex, rowData){
	e.preventDefault();
	var selected=$("#list").datagrid('getRows'); //获取所有行集合对象
	id = selected[rowIndex].id; //index为当前右键行的索引，指向当前行对象
	$('#mm').menu('show', {
	    left:e.pageX,
	    top:e.pageY
	});       
}

//查询模板表列
function showA1TemplateColumns(){
	Open1('模板表列:'+id,'admin123/template/columnList.jsp?a1TemplateTableId='+id);
}
function showA1TemplateCondition(){
	Open1('模板表查询条件:'+id,'/admin123/template/conditionList.jsp?a1TemplateTableId='+id);
}
function showA1TemplateRightMenu(){
	Open1('右击菜单:'+id,'/admin123/template/rightMenuList.jsp?a1TemplateTableId='+id);
}

function Open1(text,url){
	window.parent.Open('右击菜单:'+id,url);
}
</script>

<style type="text/css">
	.west{
		width: 200px;
		padding: 3px; 
		style="overflow-y:auto; 
		overflow-x:hidden;"
	}
	.center{
		padding: 3px;
	}
</style>

</head>

    
<body class="easyui-layout" style="margin: 2px;">
	<div region="west" class="west" title="条件搜索">
        <jsp:include page="../condition.jsp"></jsp:include>
	</div>
	<div region="center" class="center" title="查询列表">
         <table id="list" width="100%" ></table>
	</div>
	
	<!-- 右击菜单 -->
	<div id="mm" class="easyui-menu" style="width:120px;">
	    <div onClick="showA1TemplateColumns()" data-options="iconCls:'icon-add'">管理模板表列</div>
	    <div onClick="showA1TemplateCondition()" data-options="iconCls:'icon-add'">管理模板表查询条件</div>
	    <div onClick="showA1TemplateRightMenu()" data-options="iconCls:'icon-add'">管理右击菜单</div>
	</div>
	
	
	<!-- 添加表对话框 -->
	<div id="A1TemplateTable" style="display:none;padding:5px;width:500px; height: 300px" title="添加模板表"> 
		<table class="table3" cellpadding="0" cellspacing="0" align="center" width="100%">
			<tr>
				<td>
					<span>表名:</span>
					<div>
						<input id="tableName" name="tableName" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>表名显示名:</span>
					<div>
						<input id="tableNameShow" name="tableNameShow" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>主键:</span>
					<div>
						<input id="primaryKey" name="primaryKey" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
		</table>
	</div>
	
</body>
</html>